import 'package:flutter/material.dart';
import 'package:flutter_app/interface/base_net_state.dart';
import 'package:flutter_app/interface/mvp.dart';
import 'package:flutter_app/widget/loading.dart';

/// 加载中视图基类
abstract class BaseLoadingView<T extends StatefulWidget> extends BaseNetState<T>
    implements IView {
  /// 对话框
  Loading _loading = Loading(text: '正在加载中...');

  @override
  void onSuccess() {
    this.onHideLoading();
  }

  @override
  void onFailed(String msg) {
    this.onHideLoading();
  }

  @override
  void onHideLoading() {
    //关闭对话框
    this._loading.dismiss();
  }

  @override
  void onShowLoading() {
// 显示对话框
    showDialog(
        context: context,
        barrierDismissible: false, // 设置点击外部不可取消
        builder: (BuildContext context) {
          return this._loading;
        });
  }
}
